<!Doctype html>
<html>
<head>
<title>京东轮播图</title>
<meta charset="utf-8"/>
<style type="text/css">
	*{
		margin:0;
		padding:0;
	}
	ul{list-style:none;}
	a{
		text-decoration:none;
	}
	img{
		border:0;
		vertical-align:bottom;
	}
	#box{
		height:454px;
		width:730px;
		margin:50px auto;
		position:relative;
	}
	.list1 li{
		position:absolute;
		opacity:0;
	}
	.list1 .first{opacity:1;}
	.list2{
		position:absolute;
		bottom:10px;
		width:100%;
		text-align:center;
	}
	.list2 li{
		background:#3e3e3e;
		color:#fff;
		font-size:12px;
		text-align:center;
		height:18px;
		width:18px;
		border-radius:50%;
		display:inline-block;
		cursor:pointer;
	}
	.list2 .lii1{background:#b61b1f;}
	#btn a{
		position:absolute;
		width:28px;
		height:62px;
		background:rgba(0,0,0,.2);
		top:50%;
		margin-top:-31px;
		text-align:center;
		color:#fff;
		line-height:62px;
	}
	#btn #right-btn{right:0;}
	
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
(function($){
	$(function(){
		var iCurIndex=0,
			timer=null;
		//box的移入移出
		$('#box').mouseover(function(){
			clearInterval(timer);
			$('#btn').css('display','block');
		});
		$('#box').mouseout(function(){
			autoMove();
			$('#btn').css('display','none');
		});
		//向左运动
		$('#left-btn').click(function(){
			iCurIndex--;
			move();
		});
		//向右运动
		$('#right-btn').click(function(){
			iCurIndex++;
			move();
		});
		//自由运动
		autoMove();
		function autoMove(){
			timer=setInterval(function(){
				iCurIndex++;
				move();
			},3000);
		}
		$('.list2').on('mouseover','li',function(){
			//console.log(1);
			var iIndex=$(this).index();
			if(iIndex===iCurIndex){
				return;
			}
			iCurIndex=iIndex;
			move();
		});
		function move(){
			//alert(123)
			if(iCurIndex>=$('.list2 li').length){
				iCurIndex=0;
			};
			if(iCurIndex<0){
				iCurIndex=$('.list2 li').length-1;
			};
			$('.list1 li').stop(true).animate({
				opacity:0
			},500).eq(iCurIndex).stop().animate({
				opacity:1
			},500);
			$('.list2 li').removeClass('lii1').eq(iCurIndex).addClass('lii1');
		}
	});
})(jQuery);
</script>
</head>
<body>
<div id="box">
	<ul class="list1">
		<li class="first"><a href="javascript:;"><img src="images/1.jpg"/></a></li>
		<li><a href="javascript:;"><img src="images/2.jpg"/></a></li>
		<li><a href="javascript:;"><img src="images/3.jpg"/></a></li>
		<li><a href="javascript:;"><img src="images/4.jpg"/></a></li>
		<li><a href="javascript:;"><img src="images/5.jpg"/></a></li>
		<li><a href="javascript:;"><img src="images/6.jpg"/></a></li>
	</ul>
	<ul class="list2">
		<li class="lii1">1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
		<li>5</li>
		<li>6</li>
	</ul>
	<div id="btn">
		<a id="left-btn" href="javascript:;"><</a>
		<a id="right-btn" href="javascript:;">></a>
	</div>
</div>
</body>
</html>








